using System;
using System.IO;
using System.Web.Mvc;

namespace SmallMvc
{
    public abstract class SmallView : XHtml, IView
    {
        public static MagicNamelessElementUsedToCollectChildren Children
        {
            get { return new MagicNamelessElementUsedToCollectChildren(); }
        }

        public abstract void Render(ViewContext viewContext, TextWriter writer);
    }

    public abstract class SmallView<TModel> : SmallView where TModel : class
    {


        public override void Render(ViewContext viewContext, TextWriter writer)
        {
            UrlResolver = new UrlResolver(new HttpContextProvider());// viewContext.HttpContext);
            ViewContext = viewContext;
            writer.Write(Render(viewContext.ViewData.Model as TModel));
        }

        protected UrlResolver UrlResolver { get; private set; }

        protected ViewContext ViewContext { get; private set; }

        protected abstract string Render(TModel model);
    }
}